-
Notifications
You must be signed in to change notification settings - Fork 2.2k
libct/nsenter/nsenter_test.go: fix and improve #3158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
left some comments/questions, but don't think they're blockers
06d98dc to
de7ec14
Compare
|
Rebased; renamed |
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
|
@AkihiroSuda PTAL |
|
Had to rebase after #3144 merge. @thaJeztah @AkihiroSuda PTAL |
de7ec14 to
940d66d
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
libcontainer/nsenter/nsenter_test.go
Outdated
|
|
||
| if err := cmd.Start(); err != nil { | ||
| t.Fatalf("nsenter failed to start %v", err) | ||
| t.Fatal("nsenter failed to start:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? The previous form seems completely legit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A semicolon was missing. While adding it, I guess I decided to simplify it, that's it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other reason is, I was using the same form in the subsequent patches, so I added it here, too, for uniformity.
Nevermind though, I re-did this commit so it uses %v in this and similar cases, and moved the patch to be the last one.
PTAL @AkihiroSuda
1. Make sure we close all file descriptors at the end of the test. 2. Make sure we close child fds after the start. 3. Use newPipe for logs as well, for simplicity and uniformity. Signed-off-by: Kir Kolyshkin <[email protected]>
The test was not working since at least commit 64bb59f renamed pid to stage2_pid (or maybe even earlier), so the pid was never received (i.e. pid.Pid was 0). The problem was not caught because os.FindProcess never return an error on Unix. Factor out and fix pid decode function: - use DisallowUnknownInput to get error if JSON will be changed; - check pids to make sure they are valid - and use unix.Wait4 to reap zombies. Signed-off-by: Kir Kolyshkin <[email protected]>
Instead of reading a single message, do read all the logs from the init, and use DisallowUnknownFields for stricter checking. While at it, use reapChildren to reap zombies (and add an extra check). Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
- add missing colons before error message; - unify error messages after cmd.Start and cmd.Wait, so that they show context and the error itself. Signed-off-by: Kir Kolyshkin <[email protected]>
940d66d to
33dcb99
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still LGTM
Fix and improve nsenter_test.go (originally part of #3114).